<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="quo" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="contractUpSaleSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
          <el-button @click="gotoPage('/crm/sale/ContractDetailsSale?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 报价管理 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="24">
                <el-form-item label="条形码" prop="">
                  {{quo.quo_barcode}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="编号" prop="quo_num">
                  <el-input v-model="quo.quo_num" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主题" prop="quo_theme">
                  <el-input v-model="quo.quo_theme" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="客户" prop="">
                  {{quo.quo_client}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="联系人" prop="quo_contact">
                  <el-select style='width:100%' v-model="quo.quo_contact">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in person" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="订单日期" prop="quo_finishdate">
                  <el-date-picker v-model="quo.quo_finishdate" type="date" style='width:100%' value-format="yyyy-MM-dd" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="失效日期" prop="quo_faildate">
                  <el-date-picker v-model="quo.quo_faildate" type="date" style='width:100%' value-format="yyyy-MM-dd" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="合同状态" prop="quo_state">
                  <el-select style='width:100%' v-model="quo.quo_state">
                    <el-option label="待执行" value="0" />
                    <el-option label="执行中" value="1" />
                    <el-option label="已完成" value="2" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="内部描述" prop="quo_insides">
                  <el-input type="textarea" v-model="quo.quo_insides" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <div class="form-unit">
            <span class="mvc-title-left"> 列表条目 </span>
          </div>
          <el-table :data="pum">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_producenum('&CMIDpronum_id='+scope.row.pronum_id+'')">移除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="产品条形码" prop="product_barcode">
            </el-table-column>
            <el-table-column label="产品名称" prop="pronum_prodece">
            </el-table-column>
            <el-table-column label="供应商" prop="client_name">
            </el-table-column>
            <el-table-column label="产品型号" prop="product_model">
            </el-table-column>
            <el-table-column label="产品规格" prop="product_norm">
            </el-table-column>
            <el-table-column label="简要描述" prop="product_des">
            </el-table-column>
            <el-table-column label="补充" prop="pronum_remark">
            </el-table-column>
            <el-table-column label="数量" prop="pronum_no">
            </el-table-column>
            <el-table-column label="数量单位" prop="pronum_nuit">
            </el-table-column>
            <el-table-column label="单价" prop="pronum_price">
            </el-table-column>
            <el-table-column label="发货时间" prop="">
            </el-table-column>
            <el-table-column label="总价" prop="total_prices">
            </el-table-column>
          </el-table>
          <el-button @click="popOfferEntryChoice('&category_id=')" type='primary' size="mini">选择产品</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 甲乙双方责任 </span>
          </div>
          <el-table :data="s_duty">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_duty('&CMIDduty_id='+scope.row.duty_id+'')">移除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="popModifyResponsibility('&CMIDduty_id='+scope.row.duty_id+'')">修改</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="备注" prop="duty_name">
            </el-table-column>
          </el-table>
          <el-button @click="popOfferResponsibilityChoice('')" type='primary' size="mini">选择责任</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 付款方式 </span>
          </div>
          <el-table :data="s_pay">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_pay('&CMIDpay_id='+scope.row.pay_id+'')">移除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="popModificationPayment('&CMIDpay_id='+scope.row.pay_id+'')">修改</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="首次付款" prop="pay_first">
            </el-table-column>
            <el-table-column label="二次付款" prop="pay_sec">
            </el-table-column>
            <el-table-column label="尾付款" prop="pay_end">
            </el-table-column>
          </el-table>
          <el-button @click="popOfferPaymentMode('')" type='primary' size="mini">建立付款方式</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 付款账号 </span>
          </div>
          <el-table :data="s_bank">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_bank('&CMIDbank_id='+scope.row.bank_id+'')">移除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="gotoPage(''+vueparams+'')">修改</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="类型" prop="bank_type">
            </el-table-column>
            <el-table-column label="银行名称" prop="bank_tname">
            </el-table-column>
            <el-table-column label="开户姓名" prop="bank_tname">
            </el-table-column>
            <el-table-column label="银行账号" prop="bank_account">
            </el-table-column>
          </el-table>
          <el-button @click="popPaymentSelection('')" type='primary' size="mini">选择付款账号</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 违约责任 </span>
          </div>
          <el-table :data="s_breakduty">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_breakduty('&CMIDbreakduty_id='+scope.row.breakduty_id+'')">移除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="popAmendmentLiability('&CMIDbreakduty_id='+scope.row.breakduty_id+'')">修改</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="备注" prop="break_name">
            </el-table-column>
          </el-table>
          <el-button @click="popOfferContractRes('')" type='primary' size="mini">选择违约责任</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 其他要求 </span>
          </div>
          <el-table :data="s_demand">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_demand('&CMIDdemand_id='+scope.row.demand_id+'')">移除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="popModifyEequirements('&CMIDdemand_id='+scope.row.demand_id+'')">修改</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="备注" prop="demand_name">
            </el-table-column>
          </el-table>
          <el-button @click="popOfferOther('')" type='primary' size="mini">选择其他要求</el-button>
          <div>
          </div>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'销售合同'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
    <el-dialog :visible.sync="OfferEntryChoiceVisible" append-to-body>
      <OfferEntryChoice v-if="OfferEntryChoiceVisible" ref="OfferEntryChoice" :popparams="popparams"> </OfferEntryChoice>
    </el-dialog>
    <el-dialog :visible.sync="ModifyResponsibilityVisible" append-to-body>
      <ModifyResponsibility v-if="ModifyResponsibilityVisible" ref="ModifyResponsibility" :popparams="popparams"> </ModifyResponsibility>
    </el-dialog>
    <el-dialog :visible.sync="OfferResponsibilityChoiceVisible" append-to-body>
      <OfferResponsibilityChoice v-if="OfferResponsibilityChoiceVisible" ref="OfferResponsibilityChoice" :popparams="popparams"> </OfferResponsibilityChoice>
    </el-dialog>
    <el-dialog :visible.sync="ModificationPaymentVisible" append-to-body>
      <ModificationPayment v-if="ModificationPaymentVisible" ref="ModificationPayment" :popparams="popparams"> </ModificationPayment>
    </el-dialog>
    <el-dialog :visible.sync="OfferPaymentModeVisible" append-to-body>
      <OfferPaymentMode v-if="OfferPaymentModeVisible" ref="OfferPaymentMode" :popparams="popparams"> </OfferPaymentMode>
    </el-dialog>
    <el-dialog :visible.sync="PaymentSelectionVisible" append-to-body>
      <PaymentSelection v-if="PaymentSelectionVisible" ref="PaymentSelection" :popparams="popparams"> </PaymentSelection>
    </el-dialog>
    <el-dialog :visible.sync="AmendmentLiabilityVisible" append-to-body>
      <AmendmentLiability v-if="AmendmentLiabilityVisible" ref="AmendmentLiability" :popparams="popparams"> </AmendmentLiability>
    </el-dialog>
    <el-dialog :visible.sync="OfferContractResVisible" append-to-body>
      <OfferContractRes v-if="OfferContractResVisible" ref="OfferContractRes" :popparams="popparams"> </OfferContractRes>
    </el-dialog>
    <el-dialog :visible.sync="ModifyEequirementsVisible" append-to-body>
      <ModifyEequirements v-if="ModifyEequirementsVisible" ref="ModifyEequirements" :popparams="popparams"> </ModifyEequirements>
    </el-dialog>
    <el-dialog :visible.sync="OfferOtherVisible" append-to-body>
      <OfferOther v-if="OfferOtherVisible" ref="OfferOther" :popparams="popparams"> </OfferOther>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import OfferEntryChoice from "@/views/crm/sale/OfferEntryChoice";
  import ModifyResponsibility from "@/views/crm/sale/ModifyResponsibility";
  import OfferResponsibilityChoice from "@/views/crm/sale/OfferResponsibilityChoice";
  import ModificationPayment from "@/views/crm/sale/ModificationPayment";
  import OfferPaymentMode from "@/views/crm/sale/OfferPaymentMode";
  import PaymentSelection from "@/views/crm/sale/PaymentSelection";
  import AmendmentLiability from "@/views/crm/sale/AmendmentLiability";
  import OfferContractRes from "@/views/crm/sale/OfferContractRes";
  import ModifyEequirements from "@/views/crm/sale/ModifyEequirements";
  import OfferOther from "@/views/crm/sale/OfferOther";
  export default {
    name: 'ContractUpSale',
    components: {
      OfferEntryChoice,
      ModifyResponsibility,
      OfferResponsibilityChoice,
      ModificationPayment,
      OfferPaymentMode,
      PaymentSelection,
      AmendmentLiability,
      OfferContractRes,
      ModifyEequirements,
      OfferOther,
    },
    props: ['popparams'],
    data() {
      return {
        OfferEntryChoiceVisible: false,
        OfferEntryChoiceValue: null,
        OfferEntryChoiceDesc: null,
        ModifyResponsibilityVisible: false,
        ModifyResponsibilityValue: null,
        ModifyResponsibilityDesc: null,
        OfferResponsibilityChoiceVisible: false,
        OfferResponsibilityChoiceValue: null,
        OfferResponsibilityChoiceDesc: null,
        ModificationPaymentVisible: false,
        ModificationPaymentValue: null,
        ModificationPaymentDesc: null,
        OfferPaymentModeVisible: false,
        OfferPaymentModeValue: null,
        OfferPaymentModeDesc: null,
        PaymentSelectionVisible: false,
        PaymentSelectionValue: null,
        PaymentSelectionDesc: null,
        AmendmentLiabilityVisible: false,
        AmendmentLiabilityValue: null,
        AmendmentLiabilityDesc: null,
        OfferContractResVisible: false,
        OfferContractResValue: null,
        OfferContractResDesc: null,
        ModifyEequirementsVisible: false,
        ModifyEequirementsValue: null,
        ModifyEequirementsDesc: null,
        OfferOtherVisible: false,
        OfferOtherValue: null,
        OfferOtherDesc: null,
        vueparams: this.getVUEParams(""),
        quo: {
          quo_barcode: null,
          quo_num: null,
          quo_theme: null,
          quo_client: null,
          quo_contact: null,
          quo_finishdate: null,
          quo_faildate: null,
          quo_state: null,
          quo_insides: null,
        },
        pum: [],
        s_duty: [],
        s_pay: [],
        s_bank: [],
        s_breakduty: [],
        s_demand: [],
        person: [],
        loading: false,
        Container: null,
        rules: {
          quo_num: [{
            required: true,
            message: "编号不能为空",
            trigger: 'blur',
          }],
          quo_theme: [{
            required: true,
            message: "主题不能为空",
            trigger: 'blur',
          }],
          quo_finishdate: [{
            required: true,
            message: "订单日期不能为空",
            trigger: 'blur',
          }],
          quo_faildate: [{
            required: true,
            message: "失效日期不能为空",
            trigger: 'blur',
          }],
        }
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "80299289AF2443B18EA545A4C0C37170",
        name: "客户管理右菜单",
        selected: "销售合同"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/CustomerAction/contractUpSale?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      contractUpSaleSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/crm/sale/CustomerAction/contractUpSaleSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/crm/sale/ContractDetailsSale/contractDetailsSale?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      d_producenum(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerAction/d_producenum?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_duty(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerAction/d_duty?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_pay(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerAction/d_pay?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_bank(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerAction/d_bank?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_breakduty(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerAction/d_breakduty?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_demand(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerAction/d_demand?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      c_pirce(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerAction/c_pirce?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popOfferEntryChoice(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.OfferEntryChoiceVisible = !this.OfferEntryChoiceVisible;
      },
      popModifyResponsibility(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.ModifyResponsibilityVisible = !this.ModifyResponsibilityVisible;
      },
      popOfferResponsibilityChoice(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.OfferResponsibilityChoiceVisible = !this.OfferResponsibilityChoiceVisible;
      },
      popModificationPayment(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.ModificationPaymentVisible = !this.ModificationPaymentVisible;
      },
      popOfferPaymentMode(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.OfferPaymentModeVisible = !this.OfferPaymentModeVisible;
      },
      popPaymentSelection(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.PaymentSelectionVisible = !this.PaymentSelectionVisible;
      },
      popAmendmentLiability(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.AmendmentLiabilityVisible = !this.AmendmentLiabilityVisible;
      },
      popOfferContractRes(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.OfferContractResVisible = !this.OfferContractResVisible;
      },
      popModifyEequirements(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.ModifyEequirementsVisible = !this.ModifyEequirementsVisible;
      },
      popOfferOther(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.OfferOtherVisible = !this.OfferOtherVisible;
      },
    },
  }
</script>
